<template>
    <div>
        <div class="main">
            <div class="accompanyPlay-anchor">
                <a v-for="(item,index) in list" :key="index" @click="detailLink(item)">
                    <img :src="$imgPath(item.headImg)">
                    <p>{{item.nickname}}</p>
                    <div class="accompanyPlay-anchor-msg">
                        <i class="nan" v-if="item.sex == 1">{{item.age}}</i>
                        <i class="she" v-if="item.sex == 2">{{item.age}}</i>
                        <span class="adr">{{item.city | cityFilter}}</span>
                        <span class="grade">{{item.division}}</span>
                    </div>
                    <div class="accompanyPlay-anchor-status">
                        <label class="ok">{{item.onlineStatus == 0 ? '在线' : '下线'}}</label>
                        <label class="price">￥<span>{{item.price}}/</span>{{item.priceUnit}}</label>
                    </div>
                </a>
                <p v-if="list.length == 0">暂无陪玩</p>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    props:['list','serviceId'],
    methods:{
        // 跳转到详情页
        detailLink(item){
            let routeData = this.$router.resolve({
                name:'detail',
                params:{
                    userId:item.id
                },
                query:{
                    serviceId:this.serviceId
                }
            })
            window.open(routeData.href, '_blank')
        }
    },
    filters:{
        cityFilter(val){
            if(val && val.indexOf("/") != -1){
                return val.substring(val.indexOf("/") + 1,val.length)
            }else{
                return val
            }
        }
    }
}
</script>
